package ModelLayer;
import java.util.ArrayList;

public class LendingLibary
{
    private ArrayList<Lending> lendings;
    private static LendingLibary instance;
private LendingLibary()
{
    lendings = new ArrayList<Lending>();
}

public static LendingLibary getLendingLibary()
{
if(instance == null)
{
    instance = new LendingLibary();
}
    return instance;
}
public ArrayList<Lending> getAllLendings()
{
    return lendings;
}
public void addLending(Lending lending)
{
    lendings.add(lending);
}
public void removeLending(Lending lending)
{
    lendings.remove(lendings);
}
public int getId()
{
    return id;
}
public Lending searchLendingById(int id)
{
    boolean found = false;
    int index = 0;
    Lending retLending = null;
    
    while(!found && index < lendings.size())
        {
            Lending lending = lendings.get(index);
            if(lending.getId() == id)
            {
                found = true;
                retLending = lending;
            }
            else
            {
                index++;
            }
        }
        return retLending;
    }
    

}
